home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / MacSNMP / SNMP Agents Dev Kit / SNMP Interfaces / TSNMP.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-21  |  7.2 KB  |  246 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TSNMP.h
  3.  
  4.     Contains:    SNMP Class declarations
  5.     
  6.     Copyright:    © 1991-94 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9. #ifndef __TSNMP__
  10. #define __TSNMP__
  11.  
  12.  
  13. /**********************************************************************
  14. **    Includes
  15. **********************************************************************/
  16.  
  17. #ifndef __LIBRARYMANAGER__
  18. #include <LibraryManager.h>
  19. #endif
  20.  
  21. #ifndef __SNMP__
  22. #include <SNMP.h>
  23. #endif
  24.  
  25. #ifndef __MEMORY__
  26. #include <Memory.h>
  27. #endif
  28.  
  29. #ifndef __ALIASES__
  30. #include <Aliases.h>
  31. #endif
  32.  
  33. /**********************************************************************
  34. ** Class Definitions
  35. ***********************************************************************/
  36.  
  37. // structure type references
  38.  
  39. class TSNMPAgent;
  40. class TSNMPVar;
  41. class TSNMPManagerPrv;
  42. class TSNMPMIBNode;
  43.  
  44. /**********************************************************************
  45. ** Library IDs
  46. ***********************************************************************/
  47. #define kLIB_SNMPID     "snmp:mgr$"
  48. #define kLIB_AgentID "snmp:agt$"
  49.  
  50. /**********************************************************************
  51. ** Class IDs
  52. ***********************************************************************/
  53. #define kTSNMPManagerTkn     "snmp:mgr$TSNMPBogus"
  54. #define kTSNMPManagerID     "snmp:mgr$TSNMPBogus,1.1"
  55.  
  56. #define kTSNMPConsoleTkn    "snmp:mgr$TSNMPConsole"
  57. #define kTSNMPConsoleID        "snmp:mgr$TSNMPConsole,1.1"
  58.  
  59. #define kTSNMPAgentTkn         "snmp:mgr$TSNMPAgent"
  60. #define kTSNMPAgentID         "snmp:mgr$TSNMPAgent,1.1"
  61.  
  62. #define kTSNMPVarTkn         "snmp:mgr$TSNMPVar"
  63. #define kTSNMPVarID         "snmp:mgr$TSNMPVar,1.1"
  64.  
  65. #define kTDevSNMPVarTkn     "snmp:mgr$TDevSNMPVar"
  66. #define kTDevSNMPVarID         "snmp:mgr$TDevSNMPVar,1.1"
  67.  
  68. /**********************************************************************
  69. ** Class TSNMPManager. Don't subclass, use TSNMPAgent::fSNMPManagerPtr.
  70. ***********************************************************************/
  71.  
  72. class TSNMPManager : public TDynamic
  73. {
  74. public:
  75.                     TSNMPManager();
  76.     virtual            ~TSNMPManager();
  77.         
  78. // Agent routines
  79.  
  80.     virtual OSErr    AddGroup(
  81.         TSNMPAgent*        theAgentPtr,             // who wants to give a group name to a subtree
  82.         ObjectIDPtr        theGroupIdPtr,             // all ids below this show up inside the group
  83.         StringPtr        theGroupNamePtr,        // the name that shows in the UI
  84.         short            descResID,                // resource id of description resource
  85.         short            descStrIndex ) = 0;        // index of desc string in desc string STR# resource
  86.  
  87.     virtual OSErr    SendTrap(
  88.         SNMPTrapCode    generic,                 // values defined in the SMI (RFC 1155) 
  89.         short            specific,                 // developer defined error extensions
  90.         ObjectIDListPtr    idListPtr ) = 0;        // variables sent in the trap packet
  91.  
  92. // Variable routines        
  93.  
  94.     virtual OSErr    AddMIBVar(                     // must InitTSNMPVar() first
  95.         TSNMPVar*     theVarPtr,                    // the variable to add
  96.         StringPtr    varNamePtr) = 0;            // the name that shows in the UI
  97.  
  98.     virtual OSErr    GetVariableInfo(
  99.         ObjectIDListPtr idListPtr,                 // unique specifiers for a set of variables        
  100.         short             next,                    // a powerful get-next request?
  101.         Ptr                mibletBufferPtr,        // description and value of the variables
  102.         Size            bufferSize ) = 0;        // how much space available in miblet buffer
  103.         
  104. // Registration completion notification
  105.  
  106.     virtual OSErr    RegisterDone(
  107.         TSNMPAgent*        agent) = 0;                // the agent which has completed registration
  108.  
  109.  
  110. // interface routine
  111.  
  112.     virtual unsigned long GetIFindex(            // used by agents to get the if index of
  113.         short            description,            // Network devices 
  114.         char            location) = 0;            // descriptions & locations are found in SNMP.h
  115.                                                 
  116. };
  117.  
  118.  
  119. /**********************************************************************
  120. ** Class TSNMPAgent 
  121. ***********************************************************************/
  122.  
  123. class TSNMPAgent: public TDynamic
  124. {
  125. public:
  126.                     TSNMPAgent();                // fills in fSNMPManager
  127.     virtual            ~TSNMPAgent();        
  128.     
  129.     virtual    OSErr    InitSNMPAgent(    
  130.         StringPtr    agentNamePtr,                // name of the agent that shows in the UI
  131.         short        descResID,                    // resource id of description STR#
  132.         short        descStrIndex,                // index in description STR# of agent description
  133.         short        agentVersion);                // version # of the agent -- values 0 and all negative 
  134.                                                 // values are reserved
  135.  
  136.     virtual OSErr    GetAgentFSSpec( 
  137.         FSSpec *aFSSpecPtr);                    // where variable descriptions are kept
  138.                                         
  139. friend TSNMPManagerPrv;
  140.     
  141. protected:
  142.     TSNMPManager*    fSNMPManagerPtr;            // for SNMPManager calls described above
  143.     TLibraryFile*    fAgentLibraryPtr;
  144.     
  145. private:
  146.     char            fAgentName[33];
  147.     short            fDescResID;                    
  148.     short            fDescStrIndex;
  149.     short            fAgentVersion;
  150. };
  151.  
  152.  
  153. /**********************************************************************
  154. ** Class TSNMPVar 
  155. ***********************************************************************/
  156.  
  157. class TSNMPVar : public TDynamic
  158. {
  159. public:
  160.                     TSNMPVar();
  161.     virtual            ~TSNMPVar();            
  162.     
  163.     virtual    OSErr    InitSNMPVar(                // must call inherited if overridden
  164.         TSNMPAgent*        agentPtr,                // agent that implements this variable
  165.         ObjectIDPtr     idPtr,                    // varible's object ID
  166.         short            precedence,                // lowest precedence gets priority
  167.         ASNTagType        type,                    // describes variable's encoding
  168.         SMIAccess        access,                    // maximum access allowed
  169.         short            descResID,                // resource id of description  STR# resource
  170.         short            descStrIndex);            // index of description string in STR# resource
  171.                                 
  172.     TSNMPAgent*            GetAgentPtr();        
  173.     
  174. friend TSNMPManagerPrv;
  175. friend TSNMPMIBNode;
  176. friend TSNMPPrefixNode;
  177. friend TSNMPEndNode;
  178.     
  179. private:
  180.  
  181.     virtual ObjectIDPtr    GetIDPtr();                
  182.  
  183.     ObjectIDPtr        fIDPtr;                            
  184.     TSNMPAgent*        fAgentPtr;
  185.     short            fPrecedence;
  186.     ASNTagType        fType;
  187.     SMIAccess        fAccess;
  188.     short            fDescResID;
  189.     short            fDescStrIndex;
  190.     long            fCommunities;
  191.     TSNMPMIBNode    *fParentNode;
  192.     unsigned long    fSubID;
  193.     
  194. };
  195.  
  196. /**********************************************************************
  197. ** Inline Member Functions
  198. ***********************************************************************/
  199.  
  200. inline TSNMPAgent*
  201. TSNMPVar::GetAgentPtr() { return fAgentPtr; }
  202.  
  203.  
  204. /**********************************************************************
  205. ** Class TDevSNMPVar must be subclassed by developers for their variables
  206. ***********************************************************************/
  207.  
  208. class TDevSNMPVar : public TSNMPVar
  209. {
  210. public:
  211.                     TDevSNMPVar();
  212.     virtual            ~TDevSNMPVar();            
  213.                                 
  214.     virtual OSErr    GetVariable( 
  215.         Boolean            next,                // if true then it is a get next request
  216.         ObjectIDPtr     varOIDPtr,             // unique id for variable    
  217.         VarBuf*            valuePtr ) = 0;        // where to place the value returned
  218.                 
  219.     virtual OSErr    SetVariable( 
  220.         ObjectIDPtr     varOIDPtr,             // unique id for variable
  221.         VarBuf*         valuePtr,             // value to set variable to
  222.         SetStage         action ) = 0;        // for 'simultaneous' sets
  223. };
  224.  
  225.  
  226.  
  227. /**********************************************************************
  228. ** Class TSNMPConsole must be subclassed by developers for a console
  229. ***********************************************************************/
  230.  
  231. class TSNMPConsole : public TDynamic
  232. {
  233. public:
  234.                     TSNMPConsole();
  235.     virtual            ~TSNMPConsole();
  236.                     
  237.     virtual OSErr    ReceiveRawPacket(                    // must override
  238.                         PacketPiecePtr    packetPtr,         // raw SNMP Trap packet
  239.                         TIAddressPtr     source);        // where the packet came from 
  240.  
  241. private:
  242.     TSNMPManager*    fSNMPManagerPtr;                    // Pointer to the manager
  243.     SNMPRefNum*        fConsoleInfoPtr;                    // Pointer to console info
  244. };
  245.  
  246. #endif __TSNMP__